import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AdmItemReceiveVO, AdmItemReceiveForm, AdmItemReceiveQuery, ItemTreeNode } from '@/api/general/administration/item/receive/types';

/**
 * 查询物品领用列表
 * @param query
 * @returns {*}
 */

export const listAdmItemReceive = (query?: AdmItemReceiveQuery): AxiosPromise<AdmItemReceiveVO[]> => {
  return request({
    url: '/system/admItemReceive/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物品领用详细
 * @param id
 */
export const getAdmItemReceive = (id: string | number): AxiosPromise<AdmItemReceiveVO> => {
  return request({
    url: '/system/admItemReceive/' + id,
    method: 'get'
  });
};

/**
 * 新增物品领用
 * @param data
 */
export const addAdmItemReceive = (data: AdmItemReceiveForm) => {
  return request({
    url: '/system/admItemReceive',
    method: 'post',
    data: data
  });
};

/**
 * 修改物品领用
 * @param data
 */
export const updateAdmItemReceive = (data: AdmItemReceiveForm) => {
  return request({
    url: '/system/admItemReceive',
    method: 'put',
    data: data
  });
};

/**
 * 删除物品领用
 * @param id
 */
export const delAdmItemReceive = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/admItemReceive/' + id,
    method: 'delete'
  });
};

/**
 * 删除物品领用
 * @param id
 */
export const getItemTree = (): AxiosPromise<ItemTreeNode[]>  => {
  return request({
    url: '/system/admItemStore/itemTree',
    method: 'get'
  });
};
